import {Injectable} from '@angular/core';


@Injectable()
export class LocalStorage{
	public localStorage:any;
	constructor(){
		window.localStorage ? this.localStorage = window.localStorage : console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔鏈湴瀛樺偍");
	}
	public set(key:string,value:string):void{
		this.localStorage.setItem(key,value);
	}
	public get(key:string):string{
		return this.localStorage.getItem(key);
	}
	public setJson(key:string,value:object):void{
		this.localStorage.setItem(key,JSON.stringify(value));
	}
	public getJson(key:string):object{
		return JSON.parse(this.localStorage.getItem(key));
	}
	public remove(key:string):void{
		this.localStorage.removeItem(key);
	}
	public clear():void{
		this.localStorage.clear();
	}
}